package dao.mapper.auth;

import model.auth.RolesAuthorities;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mybatis.spring.annotation.Mapper;

@Mapper("auth.RolesAuthoritiesCrudMapper")
public interface RolesAuthoritiesCrudMapper {

	@Select("select seq_a_rolesauthorities.nextval from dual")
	long selectKey();
	
	@Insert("insert into a_roles_authorities (id, roleid, authorityid) values (#{m.id}, #{m.roleid}, #{m.authorityid})")
	int insert(@Param("m") RolesAuthorities model);
	
	@Select("select * from a_rolesauthorities where id=#{id} ")
	RolesAuthorities getById(@Param("id") Long id);

	@Select("select * from a_rolesauthorities where id=#{id} and enabled=#{enabled}")
	RolesAuthorities getValidById(@Param("id") Long id, @Param("enabled") Integer enabled);
	
	@Delete("delete from a_rolesauthorities where id=#{id}")
	int deleteById(@Param("id") Long id);
}
